export const baseState = {
  reqType: 0, // 请求类别,上传文件提示文件上传中
  reqNum: 0, // 请求数量
}

export const baseMutations = {
  SET_REQ_TYPE: (state, data = 0) => {
    state.reqType = data
  },
  SET_REQ_NUM: (state, data) => {
    state.reqNum += data
  },
}

export const baseActions = {
  // 设置请求类型
  setReqType({ commit }, data = 0) {
    commit('SET_REQ_TYPE', data)
  },
  // 设置请求数量
  setReqNum({ commit, state }, data) {
    if (state.reqNum === 0 && data === -1) {
      return
    }
    commit('SET_REQ_NUM', data)
  },
}

export const baseGetters = {
  // 公共的getters
  sidebar: state => state.app.sidebar,
  language: state => state.app.language,
  size: state => state.app.size,
  device: state => state.app.device,
  visitedViews: state => state.tagsView.visitedViews,
  cachedViews: state => state.tagsView.cachedViews,
  token: state => state.user.token,
  avatar: state => state.user.avatar,
  name: state => state.user.name,
  introduction: state => state.user.introduction,
  roles: state => state.user.roles,
  role_id: state => state.user.role_id,
  permission_routes: state => state.permission.routes,
  errorLogs: state => state.errorLog.logs,
  btnQx: state => state.user.btnQx
}

